package com.stockz.ui.swing.charting.display.screen;

import java.awt.Graphics2D;

import com.stockz.core.util.BarUtil.BarValueType;
import com.stockz.scanner.screen.Screen;
import com.stockz.ui.swing.charting.display.AbstractDisplayableConfiguration;
import com.stockz.ui.swing.charting.painter.screen.ScreenMatchPainter;
import com.stockz.ui.swing.charting.util.UIChartingConstant.OVERLAY;

public abstract class AbstractDisplayableScreenConfiguration extends
		AbstractDisplayableConfiguration {

	private int[] matches;
	
	@Override
	public String toString() {
		return getFullName();
	}
	
	@Override
	public BarValueType getBarValueType() {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public void setBarValueType(BarValueType barValueType) {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void paint(Graphics2D g) {
		ScreenMatchPainter.paint(g, this);
	}
	
	@Override
	public OVERLAY getOverlay(){
		return OVERLAY.PRICE;
	}

	protected void setMatches(int[] matches){
		this.matches = matches;
	}
	
	@Override
	public boolean isOverlappable() {
		return true;
	}

	public int[] getMatches() {
		if(matches == null){
			refreshValues();
		}
		return matches;
	}
	
	@Override
	public Object getConfiguration() {
		return getScreen().getConfiguration();
	}
	
	@Override
	public void refreshValues() {
			setMatches(DisplayableScreenUtil.getScreenMatches(
					getStockChartPanel().getStockChartPanelState().getBarList(), 
					getScreen()));
	}
	
	public abstract <T extends Object> Screen<T> getScreen();
}
